<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  activity_model.php
//  www.6block.com
//  
//  Created by Will_Lee on 2011-05-17.
//  Copyright 2011 lishuzu. All rights reserved.
// 
class admin_from_model extends CI_Model
{
		function __construct(){
			parent::__construct();
			$this->fromsource = $this->config->item('fromsource');
		}
		
		// 得到活动数据
		function get_froms(){
			$froms = array();
			$query = $this->db->get("from");
			foreach ($query->result_array() as $row) {
				$froms[] = $row;
			}
			return $froms;
		}
		
		
		function get_from_by_fromid($fromid){
			if ($fromid) {
				$this->db->where('fromid', $fromid);
				$query = $this->db->get('from');
				$from = $query->row_array();
				return $from;
			}
			return false;
		}
		
		function insert_from($data){
			if ($data) {
				$this->db->insert('from', $data);
				return $this->db->insert_id();
			}
			return false;
		}
		
		function update_from($data){
			if (!empty($data['fromid'])) {
				$this->db->where('fromid', $data['fromid']);
				unset($data['fromid']);
				$this->db->update('from', $data);
				return $this->db->affected_rows();
			}
			return false;
		}
		
		function deletes_from($ids){
			if($ids){
				$this->db->where_in('fromid', $ids);
				$this->db->limit(COUNT($ids));
				$this->db->delete('from');
				if($this->db->affected_rows() <= 0){
					return false;
				}
				return true;
			}
			return false;
		}
}
?>